package exception;

public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("小程序开始了");
        try{
            String str="wetdgkjhj";
            System.out.println(str.length());
            System.out.println(str.charAt(4));
            System.out.println(Integer.parseInt(str));
            System.out.println("!!!!!!!!!!!!");


        }
        catch(NullPointerException|StringIndexOutOfBoundsException e){
            System.out.println("出现了空指针或者下标越界,并解决了");
        }catch (Exception e){
            System.out.println("出现了未知异常");//子类异常在上面 超类异常在下面
        }



        System.out.println("小程序结束了");
    }
}
